#pragma once
#include "afxcmn.h"
#include "afxwin.h"

#include "CListCtrlMoreNotifies.h"
class CToggleButton;
enum enum_RA_id;

// CPage5-Dialogfeld
const int number_of_ra_ranks = 9;

class CPage9_RAnw : public CAPage
{
        DECLARE_DYNAMIC(CPage9_RAnw)

    public:
        CPage9_RAnw(CWnd* pParent = NULL);
        virtual ~CPage9_RAnw();
        enum { IDD = IDD_DIALOG9 };

    protected:
        virtual void DoDataExchange(CDataExchange* pDX); 

        DECLARE_MESSAGE_MAP()
    public:

        CListCtrlMoreNotifies mwnd_liste;
        virtual BOOL OnInitDialog();

        void OnClassChanged();
        void OnLevelChanged();

        // list structure
        struct s_list_data
        {
            // TODO: strings are const .. so we could exchange them with const char*
            int  itemnr;

            enum_RA_id  ra_id;
            std::string name;
            std::string shortname;
            int         type;
            int         ratype;
            int         count_of_levels;
            std::string levels[number_of_ra_ranks];
            std::string reuse;

            int  currentlevel;

            CToggleButton *mwnd_but[number_of_ra_ranks];
        };

        // list of all items, which will be display in the list control
        CArray <s_list_data,s_list_data&> mdb_lines;

        void DeleteList();
        void FillList();
        BOOL GetCellRect(int iRow, int iCol, int nArea, CRect &rect);
        void UpdatePoints();
        void OnRRChanged();
        void ItemInvalidate(int nr, BOOL erase = TRUE);

        int  mn_last_description;

    private:
        void CheckPossibility(int free_points);
        void ShowUsedRRPoints(int used_points, int free_points);

    protected:
        virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
    public:
        CEdit mwnd_description;
        CEdit mwnd_pointsrest;
        CEdit mwnd_pointsused;
        CButton mwnd_checkpoints;
        CEdit mwnd_rr_needed;
        CEdit mwnd_rps_needed;

    protected:
        virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
    public:
        afx_msg void OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult);

        afx_msg void OnBnClickedCheck1();
        afx_msg void OnHdnBegintrackList1(NMHDR *pNMHDR, LRESULT *pResult);
        afx_msg void OnHdnEndtrackList1(NMHDR *pNMHDR, LRESULT *pResult);
        void UpdateControlPositions(int begin_dis, int end_dis);
        afx_msg void OnBnDoubleclickedRaReset();
};
